#pragma once
#ifdef _MANAGED
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
#endif

#include <vector>
using namespace std;

#if defined(BUILD_MANWRAP_DLL)
#	define WREXPORT __declspec ( dllexport )
#else
#	define WREXPORT __declspec ( dllimport )
#endif


#include "CMObject.h"


#if (_MANAGED)

template<class M, class N>
array<M>^ wrapNative2ManagedClassArray(const std::vector<N>& narr)
{
	array<M>^ marr = gcnew array<M>((int) narr.size());
  int i=0;
  for (vector<N>::const_iterator iter = narr.begin(); iter!=narr.end(); iter++)
  {
    marr[i] = (M) (*iter).ThisObject();
    i++;
  }
	return marr;
}

template<class M, class N>
array<M>^ wrapNative2ManagedNotWrappedArray(const vector<N>& narr)
{
	array<M>^ marr = gcnew array<M>((int) narr.size());
  int i=0;
  for (vector<N>::const_iterator iter = narr.begin(); iter!=narr.end(); iter++)
  {
    marr[i] = (*iter);
    i++;
  }
	return marr;
}

array<::System::String^>^ wrapNative2ManagedStringArray(const vector<CString>& narr);

template<class M, class N>
vector<N> wrapManaged2NativeClassArray(array<M>^ gcarr)
{
	vector<N> narr;
	size_t count = gcarr->Length;
	narr.reserve(count);
	for (UINT i=0; i<count; i++) {
		N val(gcarr[i]);
		narr.push_back(val);
	}
	return narr;
}

#endif